package com.erification.web.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.erification.web.model.Address;
import com.erification.web.model.Celephone;
import com.erification.web.model.Email;
import com.erification.web.model.Group;
import com.erification.web.model.TrueName;
import com.erification.web.model.User;
import com.erification.web.service.AddressService;
import com.erification.web.service.CelephoneService;
import com.erification.web.service.EmailService;
import com.erification.web.service.GroupService;
import com.erification.web.service.TrueNameService;
import com.erification.web.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@Controller("getAllDateAction")
public class getAllDateAction extends ActionSupport{
	@Resource 
	private UserService userService;
	@Resource
	private AddressService addressService;
	@Resource
	private CelephoneService celephoneService;
	@Resource
	private EmailService emailService;
	@Resource
	private TrueNameService trueNameService;
	@Resource
	private GroupService groupService;
	
	@Override
	public String execute() throws Exception {
		String username = (String) ActionContext.getContext().getSession().get("username");
		User user = userService.getUser(username);
		long user_id = user.getId();
		List<Address> addresses = addressService.getAll(user_id);
		List<Celephone> celephones = celephoneService.getAll(user_id);
		List<Email> emails = emailService.getAll(user_id);
		List<TrueName> truenames = trueNameService.getAll(user_id);
		List<Group> groups = groupService.getAll(user_id);
		ActionContext.getContext().getSession().put("address", addresses);
		ActionContext.getContext().getSession().put("celephone", celephones);
		ActionContext.getContext().getSession().put("email", emails);
		ActionContext.getContext().getSession().put("truename", truenames);
		ActionContext.getContext().getSession().put("group", groups);
		return SUCCESS;
	}

}
